import { getDetail, getMVurl, getSimiMv } from "@/http/modules/mv";
const { createSlice, createAsyncThunk } = require("@reduxjs/toolkit");

export const getMVurlInfo = createAsyncThunk("MVurl",async (id)=>{
    const res = await getMVurl(id);
    return res.data
})

export const getMVDetaillInfo = createAsyncThunk("MVdetail",async (id)=>{
    const res = await getDetail(id)
    return res.data
})

export const getSimiMVInfo = createAsyncThunk("SimiMV",async (id)=>{
    const res = await getSimiMv(id);
    return res.mvs
})


const MVSlice = createSlice({
    name:"MV",
    initialState:{
        mvUrl:{},
        simiMv:[],
        mvDetail:{}
    },
    extraReducers:{
        [getMVurlInfo.fulfilled](state,{payload}){
            state.mvUrl = payload;
        },
        [getMVDetaillInfo.fulfilled](state,{payload}){
            state.mvDetail = payload;
        },
        [getSimiMVInfo.fulfilled](state,{payload}){
            state.simiMv = payload;
        }
    }
})

export default MVSlice.reducer